package StudentSystem;

public class LoginWindow extends InformationSystem  {
    LoginWindow() {
        String user_id1;
        int pd=1,user_write_id;//stpd  ,wz全局变量stpd  是学生还是老师,wz 相关信息储存位置
        System.out.println("<<<登录界面>>>");
        while (pd == 1) {
            System.out.println("请输入个人数字账号>>");
            user_id1 = sr.nextLine();
            user_write_id = Integer.parseInt(user_id1);

            if (user_id1.length() == 9 || user_id1.length() == 10) {
                if (user_id1.length() == 9) {//学生
                    int s_n ;
                    for (s_n = 0; s_n < student.size(); s_n++) {
                        if (student.get(s_n).user_id == user_write_id) {
                            stpd = 0;
                            pd=0;
                            wz = s_n;
                            System.out.println("输入密码>>");
                            String pass1;
                            pass1 = sr.nextLine();
                            while (!student.get(s_n).password.equals(pass1)) {
                                System.out.println("密码错误，请重新输入密码>>");
                                pass1 = sr.nextLine();
                            }
                            break;
                        }
                    }
                    if (s_n == student.size()) {
                        System.out.print("！！账号不存在！！");
                        System.out.println("是否退出查询系统，输入102退出");
                        input1 = sr.nextInt();
                        sr.nextLine();
                        if (input1 == 102) pd = -1;
                    }
                }
                if (user_id1.length() == 10) {//教师
                    int t_n;
                    for (t_n = 0; t_n < teacher.size(); t_n++) {
                        if (teacher.get(t_n).user_id == user_write_id) {
                            stpd = 1;
                            pd=0;
                            wz = t_n;
                            System.out.println("输入密码>>");
                            String pass1;
                            pass1 = sr.nextLine();
                            while (!teacher.get(wz).password.equals(pass1)) {
                                System.out.println("密码错误，请重新输入密码>>");
                                pass1 = sr.nextLine();
                            }
                            break;
                        }
                    }
                    if (t_n == teacher.size()) {
                        System.out.print("！！账号不存在！！");
                        System.out.println("是否退出查询系统，输入102退出");
                        input1 = sr.nextInt();
                        sr.nextLine();
                        if (input1 == 102) pd = -1;
                    }

                }
            }
            else {
                System.out.print("！！账号错误！！");
                System.out.println("是否退出查询系统，输入102退出");
                input1 = sr.nextInt();
                sr.nextLine();
                if (input1 == 102) pd =-1;
            }

        }

    }
}
